package com.itouch.bracelet.activity;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.itouch.bracelet.R;
import com.itouch.bracelet.adapter.ChildSelectAdapter;
import com.itouch.bracelet.bean.LoginUser;
import com.itouch.bracelet.cache.UserCache;

/**
 * 孩子切换界面，大于两个孩子的时候原来设计界面无法展示需要列表选择
 * @author SunshineHu
 *
 */
public class ChildSelectActivity extends BaseActivity implements OnItemClickListener{

	private ListView listview;
	
	@Override
	protected int setContentViewById() {
		// TODO Auto-generated method stub
		return R.layout.activity_child_select;
	}

	@Override
	protected void initViews() {
		// TODO Auto-generated method stub
		listview=(ListView) findViewById(R.id.listview);
		listview.setOnItemClickListener(this);
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub
		listview.setAdapter(new ChildSelectAdapter(this, UserCache.getOauth(this).getChildlist()));
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		// TODO Auto-generated method stub
		LoginUser user=UserCache.getOauth(this);
		user.childPosition=position;//设置当前位置
		UserCache.saveOAuth(user, this);
		finish();
	}

}
